#include "mainwindow.h"
#include <QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("127.0.0.1");
    db.setPort(3306);
    db.setDatabaseName(Databasename);//数据库名字
    db.setUserName(Username);//用户名
    db.setPassword(Userpasswd);//密码
    bool ok = db.open();
    if(ok){
        QMessageBox::information(NULL,"infor","mysql link success");
    }
    else{
        QMessageBox::information(NULL,"infor","mysql link failed");
    }


    QSqlQuery query;
    query.prepare("insert into software (id,NameOfSoftware,DownloadPath,SizeOfSoftware,UpdatingTime) values (?,?,?,?,?)");	//书写语句模型
    //添加绑定数据
    QVariantList idList;    //创建一个id列表
    idList << 1<<2<<3<<4;
    query.addBindValue(idList); //完成第一个?的绑定
    QVariantList NameOfSoftwareList;
    NameOfSoftwareList << "Jami"<<"Retroarch"<<"Litteris"<<"Postman";
    query.addBindValue(NameOfSoftwareList);   //完成第二个?的绑定
    QVariantList DownloadPathList;
    DownloadPathList <<"https://dl.jami.net/ring-manual/ubuntu_22.10/jami-all_amd64.deb"<<"https://dl.flathub.org/repo/appstream/org.libretro.RetroArch.flatpakref"<<" "<<"https://dl.pstmn.io/download/latest/linux64";
    query.addBindValue(DownloadPathList);    //完成第三个?的绑定
    QVariantList SizeOfSoftwareList;
    SizeOfSoftwareList <<236<<3.93<<000<<164;
    query.addBindValue(SizeOfSoftwareList);   //完成第四个?的绑定
    QVariantList UpdatingTimeList;
    UpdatingTimeList <<"2023.1.6"<<"2023.1.6"<<"2023.1.6"<<"2023.1.6";
    query.addBindValue(UpdatingTimeList);   //完成第五个?的绑定
    //执行批处理
    query.execBatch();



    return a.exec();
}
